 //
//  InventoryViewController.m
//  daogouApp
//
//  Created by panquanReabam.com on 15-6-2.
//  Copyright (c) 2015年 jiezsoft.com. All rights reserved.
//
#import "InventoryViewController.h"
#import "HttpRequest.h"
#import "TagView.h"
#import "UIViewExt.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "InventoryCell.h"
#import "UIButton+WebCache.h"
//#import "CheckVouchAddViewController.h"
#import "BusinessOrderExtAddViewController.h"
#import "WhsInAddViewController.h"
@interface InventoryViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate>
@property(nonatomic,strong)NSString*DocType;

@end
@implementation InventoryViewController
{   UIView*submitView;
    UIView*submitV;
    UILabel*name;
    UIButton*totalPriceLabel;
    UILabel* InventoryLabel;
    UITableView *table;
}
@synthesize alt = alt;
@synthesize mDelegate;
-(void)BackAction:(UIButton *)sender{
    
    [mDelegate secondViewController:self itemCodeArray:self.itemCodeArray scanStockResultArray:self.itemCodeArray itemUrlArray:self.itemUrlArray howArray:self.howArray itemPriceArray:self.itemPriceArray currentSpecIdArray:self.currentSpecIdArray itemNameArray:self.itemNameArray itemidArray:self.itemidArray specNameArray:self.specNameArray];
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated
{[super viewDidDisappear:animated];
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setNavi];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    table.delegate = self;
    table.dataSource = self;
    table.separatorStyle=UITableViewCellSeparatorStyleNone;
    [table registerClass:[InventoryCell class] forCellReuseIdentifier:@"InventoryViewController"];
    [self.view addSubview:table];
    totalPriceLabel=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-45, ScreenWidth*430/750, 45)];
    totalPriceLabel.backgroundColor=backColor;
    [totalPriceLabel setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    totalPriceLabel.alpha=0.8;
    [self.view addSubview:totalPriceLabel];
    UIButton*tijiao=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth*430/750, ScreenHeight-45, ScreenWidth*320/750, 45)];
    [tijiao setTitle:@"提交" forState:UIControlStateNormal];
    tijiao.backgroundColor=luseColor;
    [tijiao setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [tijiao addTarget:self action:@selector(submit:) forControlEvents:UIControlEventTouchUpInside];
    [tijiao setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:tijiao];
    [self requestData];
}
-(void)requestData{
    [table reloadData];
    if (self.itemNameArray.count==0) {
        name=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
        name.text= @"请搜索或者扫描商品开始服务！";
        name.textAlignment=NSTextAlignmentCenter;
        name.backgroundColor=[UIColor whiteColor];
        name.font= [UIFont systemFontOfSize:contenfot];
        [name setTextColor:[UIColor blackColor]];
        [self.view addSubview:name];
    }else {
        [name  removeFromSuperview];
        NSMutableArray*  sum=[[NSMutableArray alloc]init];
        for (int i=0; i<self.itemPriceArray.count; i++) {
            NSString *typeCode1 = [self.itemPriceArray objectAtIndex:i];
            NSString *isSingle1 = [self.howArray objectAtIndex:i];
            [sum addObject:[NSString stringWithFormat:@"%.2f",  [typeCode1 doubleValue]*[isSingle1 doubleValue]]];
        }
        NSNumber *sum11 = [sum valueForKeyPath:@"@sum.floatValue"];
        NSString*GoldPrice=[NSString stringWithFormat:@"%@",sum11];
        NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        [numberFormatter setPositiveFormat:@"###,##0.00;"];
        NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
        [self priceStr:formattedNumberString];
       

    }
    UIView*heardView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth,80/2)];
    heardView.backgroundColor=zuiqianhuiColor;
    table .tableHeaderView=heardView;
    NSNumber *su = [self.howArray valueForKeyPath:@"@sum.floatValue"];
    InventoryLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 25/2, 250, 14)];
    InventoryLabel.text=[NSString stringWithFormat:@"共有 %@ 条扫描记录",su];
    InventoryLabel.textColor=shenhuiColor;
    InventoryLabel.font=[UIFont systemFontOfSize:14];
    [heardView addSubview:InventoryLabel];
    UIButton*delete = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-35,20/2, 20, 20)];
    [delete setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
    [delete addTarget:self action:@selector(delete:) forControlEvents:UIControlEventTouchUpInside];
    [heardView addSubview:delete];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];

}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0) {
        [self.itemidArray removeAllObjects];
        [self.itemCodeArray removeAllObjects];
        [self.itemUrlArray removeAllObjects];
        [self.itemPriceArray removeAllObjects];
        [self.currentSpecIdArray removeAllObjects];
        [self.howArray removeAllObjects];
        [self.itemNameArray removeAllObjects];
        [self requestData];}
}
-(void)delete:(UIButton*)sender{
    UIAlertView*altss = [[UIAlertView alloc] initWithTitle:@"温馨提示 确认清空吗？" message:nil delegate:self cancelButtonTitle:@"确认" otherButtonTitles:@"取消",  nil];
    [altss show];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.itemUrlArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    InventoryCell *cell = [tableView dequeueReusableCellWithIdentifier:@"InventoryViewController"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell.imagebtn setImageWithURL:[NSURL URLWithString:[self.itemUrlArray objectAtIndex:indexPath.row]]];
    cell.createDate.text =[NSString stringWithFormat:@"%@%@",[self.itemNameArray objectAtIndex:indexPath.row],[self.itemCodeArray objectAtIndex:indexPath.row]];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",[self.itemPriceArray objectAtIndex:indexPath.row]];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    
    cell.priceLabel.text =[NSString stringWithFormat:@"￥%@",  formattedNumberString];
    NSMutableAttributedString *AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"￥%@",  formattedNumberString]];
    [AttributedStr2 addAttribute:NSFontAttributeName
     
                           value:[UIFont systemFontOfSize:12]
     
                           range:NSMakeRange(0, 1)];
    
    [AttributedStr2 addAttribute:NSForegroundColorAttributeName
     
                           value:zhonghuiColor
     
                           range:NSMakeRange(0, 1)];
    
    cell.priceLabel.attributedText = AttributedStr2;
    cell.howLabel.text=[NSString stringWithFormat:@"%@",  [self.howArray objectAtIndex:indexPath.row]];
    cell.how=[NSString stringWithFormat:@"%@",  [self.howArray objectAtIndex:indexPath.row]];
    UIImageView*shuimageview=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-180, 70, 165, 35)];
    shuimageview .image=[UIImage imageNamed:@"tianjias"];
    [cell.contentView addSubview:shuimageview];
    UIButton*jian=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-180, 70, 30, 35)];
    jian.tag=indexPath.row;
    [jian addTarget:self action:@selector(jian:) forControlEvents:UIControlEventTouchUpInside];
    [cell.contentView addSubview:jian];
    UIButton*jia=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-50,70, 30, 35)];
    jia.tag=indexPath.row;
    [jia addTarget:self action:@selector(jia:) forControlEvents:UIControlEventTouchUpInside];
    [cell.contentView addSubview:jia];
if (self.howArray.count !=indexPath.row+1) {
        UILabel *lineLabel11=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
        lineLabel11.backgroundColor=[UIColor groupTableViewBackgroundColor];;
        [cell.contentView addSubview:lineLabel11];
        
    }
    
    if (self.howArray.count ==indexPath.row+1) {
        UILabel *lineLabel11=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
        lineLabel11.backgroundColor=[UIColor groupTableViewBackgroundColor];
        [cell.contentView addSubview:lineLabel11];
        
    }
    
    return cell;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 120;
}

#pragma mark - Table view delegate

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  UITableViewCellEditingStyleDelete;
    
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    return YES;
}

-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
return @"删除";
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.itemidArray removeObjectAtIndex:indexPath.row];//从指定索引移除
    [self.itemCodeArray removeObjectAtIndex:indexPath.row];//从指定索引移除
    [self.itemUrlArray removeObjectAtIndex:indexPath.row];//从指定索引移除
    [self.itemPriceArray removeObjectAtIndex:indexPath.row];//从指定索引移除
    [self.currentSpecIdArray removeObjectAtIndex:indexPath.row];//从指定索引移除
    [self.howArray  removeObjectAtIndex:indexPath.row];//从指定索引移除
    [self.itemNameArray removeObjectAtIndex:indexPath.row];//从指定索引移除
    [self.specNameArray removeObjectAtIndex:indexPath.row];//从指定索引移除
    [table deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    [self requestData];
    
}
#pragma mark - Table view delegate

-(void)jia:(UIButton*)sender{
    UIButton* button=(UIButton * )sender;
    InventoryCell* cell=(InventoryCell* )button.superview.superview;
    int d;
    d= cell.howLabel.text.intValue;
    d++;
    NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:self.howArray];
    [mutableArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
    self.howArray = mutableArray;//now the array has been "updated"
    self.howArray=[self.howArray mutableCopy];
    cell.howLabel.text=[NSString stringWithFormat:@"%d", d];
    [self heji];
}
-(void)heji{
    [name  removeFromSuperview];
    NSMutableArray*  sum=[[NSMutableArray alloc]init];
    for (int i=0; i<self.itemPriceArray.count; i++) {
        
        NSString *typeCode1 = [self.itemPriceArray objectAtIndex:i];
        NSString *isSingle1 = [self.howArray objectAtIndex:i];
        [sum addObject:[NSString stringWithFormat:@"%.2f",  [typeCode1 doubleValue]*[isSingle1 doubleValue]]];
    }
    NSNumber *sum11 = [sum valueForKeyPath:@"@sum.floatValue"];
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",sum11];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    [self priceStr:formattedNumberString];
    NSNumber *su = [self.howArray valueForKeyPath:@"@sum.floatValue"];
    InventoryLabel.text=[NSString stringWithFormat:@"共有 %@ 条扫描记录",su];
}
-(void)jian:(UIButton*)sender{
    UIButton* button=(UIButton * )sender;
    InventoryCell* cell=(InventoryCell* )button.superview.superview;
   if ([cell.howLabel.text isEqualToString:@"1"]) {
        [self showAlertMessage:@"数量不能为 0 件！"];
    }else{
    int d;
    d= cell.howLabel.text.intValue;
    d--;
    NSLog(@"---------%ld",sender.tag);
    NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:self.howArray];
    [mutableArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
    self.howArray = mutableArray;//now the array has been "updated"
    self.howArray=[self.howArray mutableCopy];
    cell.howLabel.text=[NSString stringWithFormat:@"%d", d];
    [self heji];
    }
}

-(void)priceStr:(NSString *)str {
    [totalPriceLabel setTitle:[NSString stringWithFormat:@"  合计 ￥%@",str] forState:UIControlStateNormal];
    NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"  合计 ￥%@",str]];
    
    [AttributedStr1 addAttribute:NSFontAttributeName
     
                           value:[UIFont systemFontOfSize:14.0]
     
                           range:NSMakeRange(0, 6)];
    
    [AttributedStr1 addAttribute:NSForegroundColorAttributeName
     
                           value:[UIColor whiteColor]
     
                           range:NSMakeRange(0, 6)];
    totalPriceLabel.titleLabel.attributedText = AttributedStr1;
    
}
- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
-(void)chooseBtn:(UIButton*)sender{//提交
    [submitView removeFromSuperview];
    [submitV removeFromSuperview];
    if (sender.tag==0) {
        WhsInAddViewController *detailViewController = [[WhsInAddViewController alloc] init];
        detailViewController.titleName=@"确认陈列";
        detailViewController.Whs=@"Shelf";
        detailViewController. specNameArray=self.specNameArray;
        detailViewController. itemCodeArray=self.itemCodeArray;
        detailViewController. itemNameArray=self.itemNameArray;
        detailViewController. itemIdArray=self.itemidArray;
        detailViewController. specIdArray=self.currentSpecIdArray;
        detailViewController. dealPriceArray=self.itemPriceArray;
        detailViewController. quantityArray=self.howArray;
        detailViewController. headImageFullArray=self.itemUrlArray;//图片
        [self.navigationController pushViewController:detailViewController animated:YES];
    }
    if (sender.tag==1) {
        WhsInAddViewController *detailViewController = [[WhsInAddViewController alloc] init];
        detailViewController.titleName=@"确认出库";
        detailViewController.Whs=@"WhsOut";
        detailViewController.Type=@"WhsOutType";
        detailViewController. specNameArray=self.specNameArray;
        detailViewController. itemCodeArray=self.itemCodeArray;
        detailViewController. itemNameArray=self.itemNameArray;
        detailViewController. itemIdArray=self.itemidArray;
        detailViewController. specIdArray=self.currentSpecIdArray;
        detailViewController. dealPriceArray=self.itemPriceArray;
        detailViewController. quantityArray=self.howArray;
        detailViewController. headImageFullArray=self.itemUrlArray;//图片
        [self.navigationController pushViewController:detailViewController animated:YES];

    }
    if (sender.tag==2) {
        WhsInAddViewController *detailViewController = [[WhsInAddViewController alloc] init];
        detailViewController.titleName=@"确认入库";
        detailViewController.Whs=@"WhsIn";
        detailViewController.Type=@"WhsInType";
        detailViewController. specNameArray=self.specNameArray;
        detailViewController. itemCodeArray=self.itemCodeArray;
        detailViewController. itemNameArray=self.itemNameArray;
        detailViewController. itemIdArray=self.itemidArray;
        detailViewController. specIdArray=self.currentSpecIdArray;
        detailViewController. dealPriceArray=self.itemPriceArray;
        detailViewController. quantityArray=self.howArray;
        detailViewController. headImageFullArray=self.itemUrlArray;//图片
        [self.navigationController pushViewController:detailViewController animated:YES];

    }
    if (sender.tag==3) {
        WhsInAddViewController *detailViewController = [[WhsInAddViewController alloc] init];
        detailViewController.titleName=@"确认录入";
        detailViewController.Whs=@"CheckVouch";
        detailViewController.Type=@"CheckVouchType";
        detailViewController. specNameArray=self.specNameArray;
        detailViewController. itemCodeArray=self.itemCodeArray;
        detailViewController. itemNameArray=self.itemNameArray;
        detailViewController. itemIdArray=self.itemidArray;
        detailViewController. specIdArray=self.currentSpecIdArray;
        detailViewController. dealPriceArray=self.itemPriceArray;
        detailViewController. quantityArray=self.howArray;
        detailViewController. headImageFullArray=self.itemUrlArray;//图片
        [self.navigationController pushViewController:detailViewController animated:YES];
    }
    if (sender.tag==4) {
        [submitView removeFromSuperview];
        [submitV removeFromSuperview];
        BusinessOrderExtAddViewController *detailViewController = [[BusinessOrderExtAddViewController alloc] init];
        detailViewController. specNameArray=self.specNameArray;
        detailViewController. itemCodeArray=self.itemCodeArray;
        detailViewController. itemNameArray=self.itemNameArray;
        detailViewController. itemIdArray=self.itemidArray;
        detailViewController. specIdArray=self.currentSpecIdArray;
        detailViewController. dealPriceArray=self.itemPriceArray;
        detailViewController. quantityArray=self.howArray;
        detailViewController. headImageFullArray=self.itemUrlArray;//图片
        NSMutableArray*  sum=[[NSMutableArray alloc]init];
        for (int i=0; i<self.itemPriceArray.count; i++) {
            
            NSString *typeCode1 = [self.itemPriceArray objectAtIndex:i];
            NSString *isSingle1 = [self.howArray objectAtIndex:i];
            
            [sum addObject:[NSString stringWithFormat:@"%.2f",  [typeCode1 doubleValue]*[isSingle1 doubleValue]]];
        }
        NSNumber *sum11 = [sum valueForKeyPath:@"@sum.floatValue"];
        NSString*GoldPrice=[NSString stringWithFormat:@"%@",sum11];
        detailViewController. TotalMoney=GoldPrice;//合计
        [self.navigationController pushViewController:detailViewController animated:YES];
}}
-(void)submit:(UIButton*)sender{
    submitView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    submitView.backgroundColor=[UIColor blackColor];
    submitView.alpha=0.48;
    [self .view addSubview:submitView];
    submitV=[[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight*860/1334, ScreenWidth, ScreenHeight)];
    submitV.backgroundColor=[UIColor whiteColor];
    submitV.alpha=1;
    [self .view addSubview:submitV];
    UILabel*liness=[[UILabel alloc]initWithFrame:CGRectMake(15, 25, ScreenWidth-30, 0.35)];
    liness.backgroundColor=qianhuiColor;
    [submitV addSubview:liness];
    UILabel*zhuying=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2-30, 15, 60, 14)];
    zhuying.text=@"提交到";
    zhuying.textAlignment=NSTextAlignmentCenter;
    zhuying.textColor=zhonghuiColor;
    zhuying.backgroundColor=[UIColor whiteColor];
    zhuying.font=[UIFont systemFontOfSize:14];
    [submitV addSubview:zhuying];
    NSArray *labelArray = @[@"陈列",@"入库",@"出库",@"盘点",@"订单"];
    NSArray *imageArray = @[@"yangpinchenlie",@"shangpinruku",@"shangpinchuku",@"kucunpandian",@"xiaoshoudingdan"];
    UIImageView *_xiansubmitV = [[UIImageView alloc]initWithFrame:CGRectMake(15,260*ScreenHeight/1334, ScreenWidth-30, 0.5)];
    _xiansubmitV.image=[UIImage imageNamed:@"hengxian"];
    [submitV addSubview:_xiansubmitV];
    for (int i = 0,j = 0; i <5; i++) {
                if (i % 4 == 0) {
                    j++;
                }
                    UIImage *img=[UIImage imageNamed:imageArray[i]];
                    UIImage *tinted = [img rt_tintedImageWithColor:luseColor ];
                    UIButton*Btn = [[UIButton alloc]init];
                    Btn.frame = CGRectMake((ScreenWidth/4)*(i%4)+ScreenWidth/4/2-15,100*ScreenHeight/1334+200*ScreenHeight/1334*(j-1),30,30);
                    Btn.titleLabel.textAlignment=NSTextAlignmentCenter;
                    [Btn setImage:tinted forState:UIControlStateNormal];
                    [Btn addTarget:self action:@selector(chooseBtn:) forControlEvents:UIControlEventTouchUpInside];
                    Btn.tag=i;
                    [submitV addSubview:Btn];
                    UIButton*Btn2 = [[UIButton alloc]init];
                    Btn2.frame = CGRectMake((ScreenWidth/4)*(i%4) ,Btn.bottom+15, ScreenWidth/4,14);
                    [Btn2 setTitle:labelArray[i] forState:UIControlStateNormal];
                    Btn2.titleLabel.textAlignment=NSTextAlignmentCenter;
                    Btn2.titleLabel.font = [UIFont systemFontOfSize: 14];
                    [Btn2 setTitleColor:qianheiColor forState:UIControlStateNormal];
                    Btn2.tag=i;
                    [Btn2 addTarget:self action:@selector(chooseBtn:) forControlEvents:UIControlEventTouchUpInside];
                    [submitV addSubview:Btn2];
    }
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [submitView addGestureRecognizer:singleFingerOne];
}
- (void)closeKeyBoad{
    [submitV removeFromSuperview];
    [submitView removeFromSuperview];
    
}
-(void)setNavi{
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
    self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    self.title = @"扫描记录";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];

   }
@end
